<?php 
class followup_model extends CI_model{

	function get_id_global($id_t){
		$q = $this->db->query("SELECT id_global
							   FROM users
							   WHERE id=$id_t");
		$ret = $q->result();
		return $ret[0]->id_global;
	}

	function list_penugasan_followup($id_g){
		$q = $this->db->query("SELECT *
							   FROM penugasan_followup pf
							   JOIN 
							   (SELECT p.id_perusahaan,p.nama_perusahaan, p.status_marketing_perusahaan, pm.id_penugasan_marketing
							   FROM penugasan_marketing pm
							   JOIN 
							   perusahaan p ON pm.id_perusahaan=p.id_perusahaan
							   ) m ON pf.id_penugasan_marketing=m.id_penugasan_marketing
							   JOIN
							   teknisi t ON pf.id_teknisi=t.id_teknisi
							   WHERE pf.id_teknisi=$id_g AND pf.deskripsi_hasil_followup IS NULL
							   ORDER BY pf.id_penugasan_followup DESC");
		return $q->result();
	}


	function isi_penugasan_followup($id){
		$q = $this->db->query("SELECT *
							   FROM penugasan_followup pf
							   JOIN 
							   (SELECT p.id_perusahaan,p.nama_perusahaan, p.status_marketing_perusahaan, pm.id_penugasan_marketing, p.keterangan_perusahaan
							   FROM penugasan_marketing pm
							   JOIN 
							   perusahaan p ON pm.id_perusahaan=p.id_perusahaan
							   ) m ON pf.id_penugasan_marketing=m.id_penugasan_marketing
							   JOIN
							   teknisi t ON pf.id_teknisi=t.id_teknisi
							   WHERE pf.id_penugasan_followup=$id");
		return $q->result();
	}
	
}
?>